function page(flag) {

	if (flag == "first") {
		$currentpage = 1;
	} else if (flag == "last") {
		$currentpage = $totalpage;
	} else if (flag == "prev") {
		if ($currentpage - 1 <= 0) {
			return;
		}
		$currentpage--;
	} else if (flag == "next") {
		if ($currentpage + 1 > $totalpage) {
			return;
		}
		$currentpage++
	} else if (!isNaN(flag)) {
		if (flag > $totalpage || flag < 1) {
			alert("超出范围");
			return;
		}
		$currentpage = flag * 1;
	}
	$("#w-page").val($currentpage);
	$offset = ($currentpage - 1) * $pagesize;
	service.getRecoveryRecords(0, $offset, $pagesize, callback);
}
var callback = function(data) {
	var json = eval("(" + data + ")");
	var list = json.list;
	$total = json.total;
	$totalpage = Math.ceil($total / $pagesize);
	$("#c-page").html($currentpage);
	$("#t-page").html($totalpage == 0 ? 1 : $totalpage);
	var str = '';
	for (i = 0; i < list.length; i++) {
		var rr = list[i];
		var status = "";
		if (rr.status == 0) {
			status = "<font color='gray'>待恢复</font>";
		} else if (rr.status == 1) {
			status = "<font color='pink'>恢复中...</font>";
		} else if (rr.status == 2) {
			status = "<font color='green'>恢复成功!</font>";
		} else if (rr.status == 3) {
			status = "<font color='red'>恢复失败!</font>";
		}

		str += "<tr><td><input type='checkbox' name='ck' value='" + rr.id
				+ "' /></td>";
		str += "<td>" + rr.path + "</td>";
		str += "<td>" + status + "</td>";
		str += "<td>" + rr.recoveryPath + "</td>";
		str += "<td><a  href='javascript:void(0)' onclick='deleteRecoveryRecords("
				+ rr.id + ")'>删除记录</a></td>";

		str += "</tr>";
	}
	if (list.length == 0) {
		str = "<tr><td colspan='6' style='text-align: center;'>暂无数据</td></tr>";
	}
	$('#rRBody').html(str);
	$("#rRBody").find("tr:odd").find("td").css("background", "#fafafa")
	$("#ckAll")[0].checked = false;

};

var service = new EbeimService();
service.getRecoveryRecords(0, $offset, $pagesize, callback);

function deleteRecoveryRecords(id) {
	var sure = confirm("确定删除?");
	if (!sure) {
		return;
	}
	service.getRecoveryRecords(id, $offset, $pagesize, callback);
	alert("删除成功!");
}

function deleteSelect() {
	var sure = confirm("确定删除所选?");
	if (!sure) {
		return;
	}
	var ids = getCkValue('ck');
	if (ids.length == 0) {
		alert("至少选择一个进行操作!");
		return;
	}
	service.deleteRecoveryRecords(ids, callback);
	alert("删除成功!");
	service.getRecoveryRecords(0, $offset, $pagesize, callback);
}